load("@fbcode_macros//build_defs:cpp_benchmark.bzl", "cpp_benchmark")
load("@fbcode_macros//build_defs:cpp_unittest.bzl", "cpp_unittest")

oncall("scm_client_infra")

cpp_unittest(
    name = "chrono",
    srcs = ["ChronoTest.cpp"],
    supports_static_listing = False,
    deps = [
        "fbsource//third-party/googletest:gtest",
        "//eden/fs/utils:chrono",
        "//folly:conv",
    ],
)

cpp_unittest(
    name = "chrono_unit",
    srcs = ["ChronoUnitTest.cpp"],
    supports_static_listing = False,
    deps = [
        "fbsource//third-party/googletest:gtest",
        "//eden/fs/utils:chrono",
    ],
)

cpp_unittest(
    name = "eden_error_test",
    srcs = ["EdenErrorTest.cpp"],
    os_deps = [
        # Needed for building RocksException on Windows
        (
            "windows",
            ["fbsource//third-party/toolchains/win:RpcRT4.Lib"],
        ),
    ],
    supports_static_listing = False,
    deps = [
        "fbsource//third-party/googletest:gtest",
        "//eden/fs/utils:eden_error",
    ],
)

cpp_unittest(
    name = "proc_util",
    srcs = ["ProcUtilTest.cpp"],
    env = {
        "TEST_DATA": "$(location //eden/fs/utils/test/test-data:test-data)",
    },
    supports_static_listing = False,
    deps = [
        "fbsource//third-party/googletest:gtest",
        "//eden/common/utils:path",
        "//eden/fs/utils:proc_util",
        "//folly:portability",
    ],
)

cpp_unittest(
    name = "process_access_log",
    srcs = ["ProcessAccessLogTest.cpp"],
    supports_static_listing = False,
    deps = [
        "fbsource//third-party/googletest:gmock",
        "fbsource//third-party/googletest:gtest",
        "//eden/common/utils:process_info_cache",
        "//eden/fs/utils:process_access_log",
    ],
)

cpp_unittest(
    name = "ring_buffer",
    srcs = ["RingBufferTest.cpp"],
    supports_static_listing = False,
    deps = [
        "fbsource//third-party/googletest:gmock",
        "fbsource//third-party/googletest:gtest",
        "//eden/fs/utils:ring_buffer",
    ],
)

cpp_unittest(
    name = "source_location",
    srcs = ["SourceLocationTest.cpp"],
    supports_static_listing = False,
    deps = [
        "fbsource//third-party/fmt:fmt",
        "fbsource//third-party/googletest:gmock",
        "fbsource//third-party/googletest:gtest",
        "//eden/fs/utils:source_location",
    ],
)

cpp_unittest(
    name = "sharded_lru_cache",
    srcs = ["ShardedLruCacheTest.cpp"],
    supports_static_listing = False,
    deps = [
        "fbsource//third-party/googletest:gmock",
        "fbsource//third-party/googletest:gtest",
        "//eden/fs/model:model",
        "//eden/fs/utils:sharded_lru_cache",
    ],
)

cpp_unittest(
    name = "glob_test",
    srcs = ["GlobMatcherTest.cpp"],
    supports_static_listing = False,
    deps = [
        "fbsource//third-party/fmt:fmt",
        "fbsource//third-party/googletest:gtest",
        "//eden/fs/utils:matcher",
    ],
)

cpp_unittest(
    name = "request_permit_vendor_test",
    srcs = ["RequestPermitVendorTest.cpp"],
    supports_static_listing = False,
    deps = [
        "fbsource//third-party/googletest:gtest",
        "//eden/fs/utils:request_permit_vendor",
    ],
)

cpp_unittest(
    name = "filter_utils_test",
    srcs = ["FilterUtilsTest.cpp"],
    supports_static_listing = False,
    deps = [
        "//eden/fs/store:filtered_backing_store",
        "//eden/fs/utils:filter_utils",
        "//folly/portability:gtest",
    ],
)

cpp_benchmark(
    name = "bench",
    srcs = [
        "ProcessAccessLogBenchmark.cpp",
    ],
    deps = [
        "fbsource//third-party/benchmark:benchmark",
        "//eden/common/utils:process_info_cache",
        "//eden/fs/utils:process_access_log",
    ],
)

# This cpp_benchmark() rule depends on a library watchman.
# We disable it on non-Facebook internal builds, just so that the open source
# build doesn't depend on watchman.  This is the only thing that requires
# watchman.
cpp_benchmark(
    name = "glob_bench_mark",
    srcs = ["GlobBenchMark.cpp"],
    deps = [
        "fbsource//third-party/benchmark:benchmark",
        "fbsource//third-party/re2:re2",
        "//eden/fs/utils:matcher",
        "//watchman/thirdparty/wildmatch:wildmatch",
    ],
)
